package cn.haohaowo.service;

import cn.haohaowo.dao.BookDao;
import cn.haohaowo.entity.Book;
import cn.haohaowo.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by luwancai on 18/5/19.
 * DESC:
 */
@Service
public class BookService {

    @Autowired
    private BookDao bookDao;

    public Book queryBookById(int bookId) {
        return bookDao.getBookById(bookId);
    }

    public List<Book> queryBooks(String type, String title, String author,
                                 String publisher, int minPrice, int maxPrice,
                                 int minRow, int pageSize) {
        return bookDao.getBooks(type, title, author, publisher, minPrice, maxPrice, minRow, pageSize);
    }

    public List<Book> queryHotBooks() {
        return bookDao.getHotBooks();
    }

    public List<Book> querySearchBooks(String keyword) {
        return bookDao.getSearchBooks(keyword);
    }

    public int saveBook(Book Book) {
        return bookDao.insertBook(Book);
    }

    public int modifyBook(Book Book) {
        return bookDao.updateBook(Book);
    }

    public void createBookTable(String tableName) {
        bookDao.createBookTable(tableName);
    }

}
